'''
Created on Aug 22, 2013

@author: marchi
'''
from math import *
XX=0;
YY=1;
ZZ=2;
p=1.6075; pinv=1.0/p;
class Ell:
    def __init__(self,Line):
        self.e=[];
        self.ax=[]
        for lines in Line:
            LineSplit=lines.split();
            a=[float(LineSplit[8]), float(LineSplit[11]), float(LineSplit[14])];
            a.sort();
            self.ax.append(a);
            self.e.append(sqrt(1-a[XX]*a[XX]/a[ZZ]/a[ZZ]));
            
    def get(self):
        return self.e;
    def Avg(self):
        avg=0.0;
        for ei in self.e:
            avg+=ei;
        avg/=len(self.e);
        print(avg);
        
    def Surf(self,n):
        self.S=[]
        for ax in self.ax:
            a=pow(ax[0],p)
            b=pow(ax[1],p)
            c=pow(ax[2],p)
            S0=4.0*pi*pow((a*b+a*c+b*c)/3.0,pinv)/n;
            self.S.append(S0);
            sum=0.0;
            for obj in self.S:
                sum+=obj;
            return sum/len(self.S);
            
    def __get_item__(self,key):
        return self.e[key]
class ReadRg:
    def __init__(self,filename):
        self.line=[];
        for line in open(filename):
            self.line.append(line);  
    def __getitem__(self, key):
        return self.line[key];
    def pippo(self):
        print('I am pippo');
